package com.custom.lotterydraw

import android.os.Build
import android.os.Bundle
import android.view.View
import android.view.Window
import android.view.WindowManager
import android.widget.Toast
import androidx.appcompat.app.AppCompatActivity
import kotlinx.android.synthetic.main.activity_main.*


class MainActivity : AppCompatActivity() {

    override fun onCreate(savedInstanceState: Bundle?) {
        //透明状态栏

        //透明状态栏
        //版本判断
        val window: Window = window
        // Translucent status bar
        window.setFlags(
            WindowManager.LayoutParams.FLAG_TRANSLUCENT_STATUS,
            WindowManager.LayoutParams.FLAG_TRANSLUCENT_STATUS
        ) //设置statusbar应用所占的屏幕扩大到全屏，但是最顶上会有背景透明的状态栏，它的文字可能会盖着你的应用的标题栏
        getWindow().addFlags(WindowManager.LayoutParams.FLAG_TRANSLUCENT_NAVIGATION)
        getWindow().addFlags(WindowManager.LayoutParams.FLAG_TRANSLUCENT_STATUS)

        super.onCreate(savedInstanceState)
        setContentView(R.layout.activity_main)
        //开始动画
        main_custom_start.setOnClickListener(View.OnClickListener {
            main_custom_start.starAnim()
        })

        main_custom_start.setIsonFinishListener(object : CustomLotteryDraw.OnisFinish {

            override fun isonFinished(isfinished: Boolean, luckname: String) {
                if (isfinished) {
                    main_tev_showisfinish.text = "点击中心抽奖"
                    if (luckname != "") {
                        Toast.makeText(this@MainActivity, luckname, Toast.LENGTH_SHORT).show()
                    }
                } else {
                    main_tev_showisfinish.text = "。。抽奖中。。"
                }
            }
        })


    }
}
